def display_menu():
    def display_menu():
        print("\n请选择操作：")
        print("1. 存款 (deposit)")
        print("2. 取款 (withdraw)")
        print("3. 查询余额 (balance)")
        print("输入 'exit' 退出系统")

    def get_initial_balance():
        while True:
            try:
                balance = float(input("请输入初始账户余额："))
                if balance < 0:
                    print("初始余额不能为负数，请重新输入。")
                    continue
                return balance
            except ValueError:
                print("输入无效，请输入一个数字。")

    def deposit(balance):
        while True:
            try:
                amount = float(input("请输入存款金额："))
                if amount <= 0:
                    print("存款金额必须大于 0，请重新输入。")
                    continue
                balance += amount
                print(f"存款成功！当前余额为：{balance:.2f} 元")
                return balance
            except ValueError:
                print("输入无效，请输入一个数字。")

    def withdraw(balance):
        while True:
            try:
                amount = float(input("请输入取款金额："))
                if amount <= 0:
                    print("取款金额必须大于 0，请重新输入。")
                    continue
                if amount > balance:
                    print("余额不足，无法完成取款！")
                    return balance
                balance -= amount
                print(f"取款成功！当前余额为：{balance:.2f} 元")
                return balance
            except ValueError:
                print("输入无效，请输入一个数字。")

    def check_balance(balance):
        print(f"当前账户余额为：{balance:.2f} 元")
        return balance

    def atm_system():
        print("欢迎使用简易 ATM 系统")
        balance = get_initial_balance()

        while True:
            display_menu()
            choice = input("请输入选项或命令：").strip().lower()

            if choice == "exit":
                print("正在退出 ATM 系统，感谢您的使用！")
                break
            elif choice in ['1', 'deposit']:
                balance = deposit(balance)
            elif choice in ['2', 'withdraw']:
                balance = withdraw(balance)
            elif choice in ['3', 'balance']:
                balance = check_balance(balance)
            else:
                print("无效的选项，请重新选择。")

    if __name__ == "__main__":
        atm_system()